<?php  if (!defined('PATH_HD')) exit('No direct script access allowed');
	class UserControl extends Control{
		//查看用户
		function index(){
			$db=M('user');
			$totle=$db->count();//获得所有用户
			$page=new page($totle,12);
			$data = $db->order('userid ASC')->limit($page->limit())->all();
			$this->assign('data',$data);
			$this->assign('page',$page->show(2));
			$this->display();
		}
		//添加用户显示视图
		function addusershow(){
			$this->display();
		}
		//执行添加用户
		function adduser(){
			$data=$_POST;
			$data['time']=time();
			$data['password']=md5($data['password']);
			$db=M('user');
			if($db->add($data)){
				$this->success("添加用户成功", "index");
			}else{
				$this->error("添加用户失败");
			}
		}
		// 修改用户锁定状态
		function changelock(){
			$db=M('user');
			if($db->save($_POST)){
				echo json_encode(array('status' => 1,'data'=>$_POST));
			}else{
				echo json_encode(array('status' => 0));
			}
			
		}
	}
?>